package com.tjhzzx.hnceCore2024.model.common;



import com.tjhzzx.hnceCore2024.enums.BModuleType;
import com.tjhzzx.hnceCore2024.model.ext.BDashboardRoot;
import com.tjhzzx.hnceCore2024.model.ext.BTreeMenuRoot;

import javax.baja.sys.Flags;
import javax.baja.sys.Property;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;

public class BCommonModule extends BBaseComponent {

    public static final Property redirectToBase = newProperty(Flags.HIDDEN, false, null);

    public boolean getRedirectToBase() {
        return getBoolean(redirectToBase);
    }

    public void setRedirectToBase(boolean v) {
        setBoolean(redirectToBase, v, null);
    }

    public static final Property baseUrl = newProperty(Flags.HIDDEN, "http://", null);

    public String getBaseUrl() {
        return getString(baseUrl);
    }

    public void setBaseUrl(String v) {
        setString(baseUrl, v, null);
    }

    public static final Property moduleType = newProperty(0, BModuleType.DEFAULT, null);

    public BModuleType getModuleType() {
        return (BModuleType) get(moduleType);
    }

    public void setModuleType(BModuleType v) {
        set(moduleType, v, null);
    }

    public static final Property pagePath = newProperty(0, "/CommonModule", null);

    public String getPagePath() {
        return getString(pagePath);
    }

    public void setPagePath(String v) {
        setString(pagePath, v, null);
    }

    public static final Property url = newProperty(0, "https://", null);

    public String getUrl() {
        return getString(url);
    }

    public void setUrl(String v) {
        setString(url, v, null);
    }

    public static final Property dashboardRoot = newProperty(0, new BDashboardRoot(), null);

    public BDashboardRoot getDashboardRoot() {
        return (BDashboardRoot) get(dashboardRoot);
    }

    public void setDashboardRoot(BDashboardRoot v) {
        set(dashboardRoot, v, null);
    }

    public static final Property treeMenuRoot = newProperty(0, new BTreeMenuRoot(), null);

    public BTreeMenuRoot getTreeMenuRoot() {
        return (BTreeMenuRoot) get(treeMenuRoot);
    }

    public void setTreeMenuRoot(BTreeMenuRoot v) {
        set(treeMenuRoot, v, null);
    }

    public static final Property moduleTypeExpose = newProperty(Flags.HIDDEN, BModuleType.expose(), null);

    public String getModuleTypeExpose() {
        return getString(moduleTypeExpose);
    }

    public void setModuleTypeExpose(String v) {
        setString(moduleTypeExpose, v, null);
    }


//    @Override
//    public void changed(Property property, Context context) {
//        super.changed(property, context);
//        if(property.getType() == BModuleType.TYPE) {
//            String tag = propertyValueToString(property, context);
//            if(tag.equals(BModuleType.dashboard.toString(context))) {
////                this.setFlags(this.getSlot("velocityName"), Flags.HIDDEN, Context.commit);
//                this.setFlags(this.getSlot("url"), Flags.HIDDEN, Context.commit);
//                this.setFlags(this.getSlot("treeMenuRoot"), Flags.HIDDEN, Context.commit);
//                this.setFlags(this.getSlot("dashboardRoot"), 0, Context.commit);
//            } else if(tag.equals(BModuleType.page.toString(context))) {
//                this.setFlags(this.getSlot("url"), Flags.HIDDEN, Context.commit);
//                this.setFlags(this.getSlot("treeMenuRoot"), Flags.HIDDEN, Context.commit);
//                this.setFlags(this.getSlot("dashboardRoot"), Flags.HIDDEN, Context.commit);
////                this.setFlags(this.getSlot("velocityName"), 0, Context.commit);
//            } else if(tag.equals(BModuleType.url.toString(context))) {
//                this.setFlags(this.getSlot("treeMenuRoot"), Flags.HIDDEN, Context.commit);
//                this.setFlags(this.getSlot("dashboardRoot"), Flags.HIDDEN, Context.commit);
////                this.setFlags(this.getSlot("velocityName"), Flags.HIDDEN, Context.commit);
//                this.setFlags(this.getSlot("url"), 0, Context.commit);
//            } else {
//                this.setFlags(this.getSlot("dashboardRoot"), Flags.HIDDEN, Context.commit);
////                this.setFlags(this.getSlot("velocityName"), Flags.HIDDEN, Context.commit);
//                this.setFlags(this.getSlot("url"), Flags.HIDDEN, Context.commit);
//                this.setFlags(this.getSlot("treeMenuRoot"), 0, Context.commit);
//            }
//        }
//    }


    public BCommonModule() {
        setTitle("通用模块");
        setNIcon("file");
    }

    @Override
    public Type getType() {
        return TYPE;
    }

    public static final Type TYPE = Sys.loadType(BCommonModule.class);
}
